﻿#region File Description
//-----------------------------------------------------------------------------
// Sprite.cs
//
// Attack of the Crazy Pixels
// Copyright (c) 2009 VosSoft
//-----------------------------------------------------------------------------
#endregion
#region License
//-----------------------------------------------------------------------------
// The MIT License (MIT)
//
// Copyright (c) 2009 VosSoft
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
#endregion

namespace Attack_of_the_Crazy_Pixels
{
    /// <summary>
    /// Basic Sprite.
    /// </summary>
    public class Sprite
    {
        public Texture2D Texture
        {
            get { return texture; }
        }
        Texture2D texture = null;

        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }
        Vector2 position = Vector2.Zero;

        public Rectangle? SourceRectangle
        {
            get { return sourceRectangle; }
        }
        Rectangle? sourceRectangle = null;

        public Color Color
        {
            get { return color; }
            set { color = value; }
        }
        Color color = Color.White;

        public float Rotation
        {
            get { return rotation; }
            set { rotation = value; }
        }
        float rotation = 0.0f;

        public Vector2 Origin
        {
            get { return origin; }
            set { origin = value; }
        }
        Vector2 origin = Vector2.Zero;

        public Vector2 Scale
        {
            get { return scale; }
            set { scale = value; }
        }
        Vector2 scale = Vector2.One;

        public SpriteEffects Effects
        {
            get { return effects; }
            set { effects = value; }
        }
        SpriteEffects effects = SpriteEffects.None;

        public float LayerDepth
        {
            get { return layerDepth; }
            set { layerDepth = value; }
        }
        float layerDepth = 0;

        public Sprite(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color,
            float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
        {
            this.texture = texture;
            this.position = position;
            this.sourceRectangle = sourceRectangle;
            this.color = color;
            this.rotation = rotation;
            this.origin = origin;
            this.scale = scale;
            this.effects = effects;
            this.layerDepth = layerDepth;
        }

        public Sprite(Texture2D texture, Vector2 position, Color color)
        {
            this.texture = texture;
            this.position = position;
            this.color = color;

            // origin is always in the center of the sprite
            origin = new Vector2(texture.Width / 2.0f, texture.Height / 2.0f);
        }

        /// <summary>
        /// Basic update logic for alle derived classes.
        /// </summary>
        /// <param name="elapsedTime">Time since the last frame (in seconds).</param>
        public virtual void Update(float elapsedTime)
        {
        }
    }
}
